package com.lyf.design.learn.designmodel.composite.sample;

import java.util.LinkedList;
import java.util.List;

/**
 * @AUTHOR LYF
 * @DATE 2022/6/9
 * @VERSION 1.0
 * @DESC
 */
public class Branch extends Node{
    List<Node> list;

    public Branch(List<Node> list) {
        this.list = list;
    }

    @Override
    void basicInfo() {
        System.out.println(name+":"+size);
    }
    void addNode(Node node){
        if(list==null){
            list = new LinkedList<>();
        }else{
            list.add(node);
            size+= node.size;
        }
    }
}
